home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Database How-To / Visual Basic 4 Database - How-to (The Waite Group)(1995).iso / maillist.fr_ / maillist.fr
Text File  |  1995-04-04  |  9KB  |  276 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMailList 
  3.    Caption         =   "Print Sorted Mailing List"
  4.    ClientHeight    =   3495
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1500
  7.    ClientWidth     =   5610
  8.    Height          =   3900
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3495
  12.    ScaleWidth      =   5610
  13.    Top             =   1155
  14.    Width           =   5730
  15.    Begin VB.CommandButton cmdQuit 
  16.       Caption         =   "&Quit"
  17.       Height          =   495
  18.       Left            =   4080
  19.       TabIndex        =   10
  20.       Top             =   2160
  21.       Width           =   1215
  22.    End
  23.    Begin VB.CommandButton cmdReport 
  24.       Caption         =   "&Print Report"
  25.       Default         =   -1  'True
  26.       Height          =   495
  27.       Left            =   2400
  28.       TabIndex        =   9
  29.       Top             =   2160
  30.       Width           =   1215
  31.    End
  32.    Begin VB.TextBox txtValue 
  33.       Height          =   285
  34.       Left            =   360
  35.       TabIndex        =   8
  36.       Top             =   1200
  37.       Visible         =   0   'False
  38.       Width           =   2055
  39.    End
  40.    Begin VB.Frame Frame1 
  41.       Caption         =   "Select Page Number Format"
  42.       Height          =   1575
  43.       Left            =   3000
  44.       TabIndex        =   4
  45.       Top             =   240
  46.       Width           =   2295
  47.       Begin VB.OptionButton optPageNoType 
  48.          Caption         =   "page &one"
  49.          Height          =   255
  50.          Index           =   2
  51.          Left            =   360
  52.          TabIndex        =   7
  53.          Top             =   1080
  54.          Width           =   1215
  55.       End
  56.       Begin VB.OptionButton optPageNoType 
  57.          Caption         =   "&1"
  58.          Height          =   255
  59.          Index           =   1
  60.          Left            =   360
  61.          TabIndex        =   6
  62.          Top             =   720
  63.          Width           =   1215
  64.       End
  65.       Begin VB.OptionButton optPageNoType 
  66.          Caption         =   "&Page 1"
  67.          Height          =   255
  68.          Index           =   0
  69.          Left            =   360
  70.          TabIndex        =   5
  71.          Top             =   360
  72.          Value           =   -1  'True
  73.          Width           =   1215
  74.       End
  75.    End
  76.    Begin VB.PictureBox Picture1 
  77.       Align           =   2  'Align Bottom
  78.       BackColor       =   &H00C0C0C0&
  79.       Height          =   495
  80.       Left            =   0
  81.       ScaleHeight     =   465
  82.       ScaleWidth      =   5580
  83.       TabIndex        =   1
  84.       Top             =   3000
  85.       Width           =   5610
  86.       Begin VB.Label lblStatus 
  87.          BackColor       =   &H00C0C0C0&
  88.          Height          =   255
  89.          Left            =   120
  90.          TabIndex        =   2
  91.          Top             =   120
  92.          Width           =   6495
  93.       End
  94.    End
  95.    Begin VB.ComboBox lstReportType 
  96.       Height          =   300
  97.       ItemData        =   "MAILLIST.frx":0000
  98.       Left            =   360
  99.       List            =   "MAILLIST.frx":0007
  100.       Style           =   2  'Dropdown List
  101.       TabIndex        =   0
  102.       Top             =   480
  103.       Width           =   2055
  104.    End
  105.    Begin VB.Label Label1 
  106.       Caption         =   "&Select Report Type:"
  107.       Height          =   195
  108.       Left            =   360
  109.       TabIndex        =   11
  110.       Top             =   240
  111.       Width           =   2055
  112.    End
  113.    Begin VB.Label lblInstruction 
  114.       AutoSize        =   -1  'True
  115.       Height          =   195
  116.       Left            =   360
  117.       TabIndex        =   3
  118.       Top             =   960
  119.       Visible         =   0   'False
  120.       Width           =   45
  121.    End
  122.    Begin Crystal.CrystalReport CrystalReport1 
  123.       Left            =   0
  124.       Top             =   1800
  125.       _extentx        =   741
  126.       _extenty        =   741
  127.       _stockprops     =   0
  128.       reportfilename  =   "d:\winword\writing\database\crystal\maillist.rpt"
  129.       destination     =   0
  130.       windowleft      =   100
  131.       windowtop       =   100
  132.       windowwidth     =   490
  133.       windowheight    =   300
  134.       windowtitle     =   ""
  135.       windowborderstyle=   2
  136.       windowcontrolbox=   -1  'True
  137.       windowmaxbutton =   -1  'True
  138.       windowminbutton =   -1  'True
  139.       copiestoprinter =   1
  140.       printfilename   =   ""
  141.       printfiletype   =   0
  142.       selectionformula=   ""
  143.       groupselectionformula=   ""
  144.       connect         =   ""
  145.       username        =   ""
  146.    End
  147. End
  148. Attribute VB_Name = "frmMailList"
  149. Attribute VB_Creatable = False
  150. Attribute VB_Exposed = False
  151. Option Explicit
  152.  
  153. Private Sub cmdQuit_Click()
  154.     End
  155. End Sub
  156.  
  157. Private Sub cmdReport_Click()
  158.     Dim ZipDigits As String
  159.     
  160.     lblStatus.Caption = "Setting report options. Please wait..."
  161.     DoEvents
  162.     
  163.     Select Case lstReportType.Text
  164.         Case "City"
  165.             'Set the filter and title for the report
  166.             If Len(txtValue) Then
  167.                 CrystalReport1.SelectionFormula = "{Mailing LIst.CITY}= '" & txtValue & "'"
  168.                 CrystalReport1.Formulas(0) = "ReportTitle= 'Mailing List for City of " & txtValue & "'"
  169.             Else
  170.                 CrystalReport1.SelectionFormula = ""
  171.                 CrystalReport1.Formulas(0) = "ReportTitle= 'Full City Mailing List'"
  172.             End If
  173.             
  174.             'Set the sort order and clear second element
  175.             CrystalReport1.SortFields(0) = "+{Mailing LIst.CITY}"
  176.             CrystalReport1.SortFields(1) = "+{Mailing LIst.ZIP}"
  177.             CrystalReport1.SortFields(2) = ""
  178.         
  179.         Case "State"
  180.             'Set the filter and title for the report
  181.             If Len(txtValue) Then
  182.                 CrystalReport1.SelectionFormula = "{Mailing LIst.STATE}= '" & txtValue & "'"
  183.                 CrystalReport1.Formulas(0) = "ReportTitle= 'Mailing List for State of " & txtValue & "'"
  184.             Else
  185.                 CrystalReport1.SelectionFormula = "{Mailing LIst.STATE}= {Mailing LIst.STATE}"
  186.                 CrystalReport1.Formulas(0) = "ReportTitle= 'Full State Mailing List'"
  187.             End If
  188.             
  189.             'Set the sort order
  190.             CrystalReport1.SortFields(0) = "+{Mailing LIst.STATE}"
  191.             CrystalReport1.SortFields(1) = "+{Mailing LIst.CITY}"
  192.             CrystalReport1.SortFields(2) = "+{Mailing LIst.ZIP}"
  193.  
  194.         Case "Zip"
  195.             'Set the filter and title for the report
  196.             If Len(txtValue) Then
  197.                 ZipDigits = Trim(Str(Len(txtValue)))
  198.                 CrystalReport1.SelectionFormula = "{Mailing LIst.ZIP}[1 to " & ZipDigits & "]= '" & txtValue & "'"
  199.                 CrystalReport1.Formulas(0) = "ReportTitle= 'Mailing List for Zip Code " & txtValue & "'"
  200.             Else
  201.                 CrystalReport1.SelectionFormula = "{Mailing LIst.ZIP}= {Mailing LIst.ZIP}"
  202.                 CrystalReport1.Formulas(0) = "ReportTitle= 'Full Zip Code Mailing List'"
  203.             End If
  204.             
  205.             'Set the sort order
  206.             CrystalReport1.SortFields(0) = "+{Mailing LIst.ZIP}"
  207.             CrystalReport1.SortFields(1) = ""
  208.             CrystalReport1.SortFields(2) = ""
  209.     End Select
  210.  
  211.     'Print the report
  212.     lblStatus.Caption = "Printing the report. Please wait..."
  213.     DoEvents
  214.     CrystalReport1.Action = 1
  215.        
  216.     lblStatus.Caption = "Enter new selections and print or quit."
  217.     DoEvents
  218.     
  219. End Sub
  220.  
  221. Private Sub Form_Load()
  222.     'Load the lstReportType list box
  223.     lstReportType.Clear
  224.     lstReportType.AddItem "City"
  225.     lstReportType.AddItem "State"
  226.     lstReportType.AddItem "Zip"
  227.     
  228.     lblStatus.Caption = "Select a report type."
  229.     
  230.     'Set the initial value of the page format
  231.     optPageNoType_Click (0)
  232. End Sub
  233.  
  234. Private Sub lstReportType_Click()
  235.     If Len(lstReportType.Text) Then
  236.         Select Case lstReportType.Text
  237.             Case "City"
  238.                 lblInstruction.Caption = "&Enter the City name:"
  239.                 lblStatus.Caption = "Enter a city name or blank for all."
  240.             Case "State"
  241.                 lblInstruction.Caption = "&Enter the State name:"
  242.                 lblStatus.Caption = "Enter a state name or blank for all."
  243.             Case "Zip"
  244.                 lblInstruction.Caption = "&Enter the Zip Code:"
  245.                 lblStatus.Caption = "Enter a zip code or blank for all."
  246.         End Select
  247.     
  248.         txtValue.Text = ""
  249.         
  250.         lblInstruction.Visible = True
  251.         txtValue.Visible = True
  252.         
  253.         txtValue.SetFocus
  254.         
  255.     Else
  256.         lblInstruction.Visible = False
  257.         txtValue.Text = ""
  258.         txtValue.Visible = False
  259.     End If
  260.     
  261. End Sub
  262.  
  263. Private Sub optPageNoType_Click(Index As Integer)
  264.     'Set the page number format
  265.     Select Case Index
  266.         Case 0
  267.             CrystalReport1.Formulas(1) = "PageFooter= 'Page ' + ToText(PageNumber, 0)"
  268.         Case 1
  269.             CrystalReport1.Formulas(1) = "PageFooter= ToText(PageNumber, 0)"
  270.         Case 2
  271.             CrystalReport1.Formulas(1) = "PageFooter= 'page ' + ToWords(PageNumber, 0)"
  272.     End Select
  273.  
  274. End Sub
  275.  
  276.